<?php 
class CFusebox {

	public function __construct() {
		return true;
	} 
	
	public static function createApplication() {
		
		$strModuleName = 'default';
		if( true == isset( $_REQUEST['module'] ) ) {
			$strModuleName = $_REQUEST['module'];
		}
				
		$strAssingApplicationPath = APPLICATION_PATH . 'CAssignApplicationModule.php';
		$strApplicationClassPath = APPLICATION_PATH;
		
		if( true == isset( $_REQUEST['application'] ) && 'admin' == $_REQUEST['application'] ) {
			$strAssingApplicationPath = ADMIN_APPLICATION_PATH . 'CAssignApplicationModule.php';
			$strApplicationClassPath = ADMIN_APPLICATION_PATH;
		}
		
		require_once( $strAssingApplicationPath );

		if( true == array_key_exists( $strModuleName, $arrstrModuleNames ) ) {
			@list( $strClassPath, $strParametes ) = @explode( '?', $arrstrModuleNames[$strModuleName] );
			
			if( true == isset( $strParametes ) ) {
				@list( $strVarName, $strVarValue ) = @explode( '=', $strParametes );
				$_GET[$strVarName] = $strVarValue;
			}
			
			$strClassPath = $strApplicationClassPath . $strClassPath; 
		} else {
			$strClassPath = $strApplicationClassPath . $arrstrModuleNames['default']; 
			$_REQUEST['action'] = 'page_not_found';
		}
		
		$arrClassExplode = array_reverse( explode( '/', $strClassPath  ) );	
		
		
		require_once( $strClassPath );
		$strClassName = str_replace( '.class.php', '', $arrClassExplode[0] );
		
		return new $strClassName();		
	} 
}
?>